package items;

import java.math.BigDecimal;
import java.math.MathContext;

public class Stockable extends Item {

	private String brand;   //marca
	private String model;   //modelo
	private String measure; //medida
	private String provider;
	private BigDecimal listPrice;
	private Double purchasePercentage;
	private Double salePercentage;
	private int stock  = 0;
	
	public Stockable(String name, BigDecimal price, Double purchasePercentage, Double salePercentage) {
		super(name);
		this.listPrice = price;
		this.purchasePercentage = purchasePercentage;
		this.salePercentage = salePercentage;
	}
	
	public Stockable(String name,String brand,String model, String measure, BigDecimal price, Double purchasePercentage, Double salePercentage) {
		super(name);
		this.brand = brand;
		this.model = model;
		this.measure = measure;
		this.listPrice = price;
		this.purchasePercentage = purchasePercentage;
		this.salePercentage = salePercentage;
	}
	
	public Stockable(String name, BigDecimal price, Double purchasePercentage, Double salePercentage,int stock) {
		super(name);
		this.listPrice = price;
		this.purchasePercentage = purchasePercentage;
		this.salePercentage = salePercentage;
		this.stock = stock;
	}
	
	public Stockable(String name,String brand,String model, String measure, BigDecimal price, Double purchasePercentage, Double salePercentage, int stock) {
		super(name);
		this.brand = brand;
		this.model = model;
		this.measure = measure;
		this.listPrice = price;
		this.purchasePercentage = purchasePercentage;
		this.salePercentage = salePercentage;
		this.stock = stock;
	}
	
	public Stockable(){}

	//-----------Methods----------------
	
	/**
	 * Devuelve el precio de compra de un Stockeable
	 * @return BigDecimal
	 */
	public BigDecimal purchasePrice(){
		Double percent = (100 - this.getPurchasePercentage())/100;
		BigDecimal result = this.getListPrice().multiply(new BigDecimal(percent), MathContext.DECIMAL32);
		return result;
	}
	
	/**
	 * Devuelve el precio de venta de un Stockeable
	 * @return BigDecimal
	 */
	public BigDecimal salePrice(){
		Double percent = (100 + this.getSalePercentage())/100;
		BigDecimal result = this.purchasePrice().multiply(new BigDecimal(percent), MathContext.DECIMAL32);
		return result;
	}
	
	
	//-----------Sett&Gett---------------
	
	public void setProvider(String proveedor) {
		this.provider = proveedor;
	}

	public String getProvider() {
		return provider;
	}

	public void setListPrice(BigDecimal listPrice) {
		this.listPrice = listPrice;
	}

	public BigDecimal getListPrice() {
		return listPrice;
	}

	public void setPurchasePercentage(Double purchasePercentage) {
		this.purchasePercentage = purchasePercentage;
	}

	public Double getPurchasePercentage() {
		return purchasePercentage;
	}

	public void setSalePercentage(Double salePercentage) {
		this.salePercentage = salePercentage;
	}

	public Double getSalePercentage() {
		return salePercentage;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getMeasure() {
		return measure;
	}

	public void setMeasure(String measure) {
		this.measure = measure;
	}

	public int getStock() {
		return stock;
	}

	public void setStock(int stock) {
		this.stock = stock;
	}

}
